import java.util.Stack;

public class Test {
    public static void main(String[] args) {
        Stack<Integer> stack1 = new Stack<>();
        stack1.push(1);
        System.out.println(stack1);
    }
    public boolean isValid(String s) {
        Stack<Character> stack = new Stack<>();
        for(int i =0 ;i < s.length();i++) {
            char ch = s.charAt(i);

            if(isfull(ch)) {
                stack.push(ch);
            }else {
                if(stack.empty()) {
                    return false;
                }
                if(stack.peek() == '(' && ch == ')' ||
                        stack.peek() == '[' && ch == ']' ||
                        stack.peek() == '{' && ch == '}') {
                    stack.pop();
                } else {
                    return false;
                }
            }
        }
        if(stack.empty()) {
            return true;
        }
        return false;
    }
    public static boolean isfull(char ch) {
        if(ch == '(' || ch == '[' || ch == '{') {
            return true;
        }
        return false;
    }
    public int evalRPN(String[] tokens) {
        Stack<Integer> stack = new Stack<>();

        for(int i = 0;i < tokens.length;i++) {
            String s = tokens[i];

            if( !isfull(s)) {
                Integer ret = Integer.valueOf(s);
                stack.push(ret);

            } else {
                int num1 = stack.pop();
                int num2 = stack.pop();
                switch(s) {
                    case "+":
                        stack.push(num2+num1);
                        break;

                    case "-":
                        stack.push(num2-num1);
                        break;

                    case "*":
                        stack.push(num2*num1);
                        break;

                    case "/":
                        stack.push(num2/num1);
                        break;
                }
            }
        }
        return stack.pop();
    }
    public boolean isfull(String s) {
        if(s.equals("+") || s.equals("-") || s.equals("*") || s.equals("/")) {
            return true;
        }
        return false;
    }
    public boolean IsPopOrder (int[] pushV, int[] popV) {
        // write code here
        Stack<Integer> stack = new Stack<>();

        int j = 0;
        for(int i =0;i < pushV.length;i++) {
            stack.push(pushV[i]);
            while(!stack.empty() && j < popV.length && stack.peek() == popV[j]) {
                stack.pop();
                j++;
            }
        }
        return stack.empty();
    }
    Stack<Integer> stack;
    Stack<Integer> minStack;


    public MinStack() {
        stack = new Stack<>();
        minStack = new Stack<>();

    }

    public void push(int val) {
        stack.push(val);
        if(minStack.empty()) {
            minStack.push(val);
        } else {
            if(val <= minStack.peek()) {
                minStack.push(val);
            }
        }
    }

    public void pop() {
        int ret = stack.pop();
        if(minStack.peek() == ret) {
            minStack.pop();
        }
    }

    public int top() {
        return  stack.peek();
    }

    public int getMin() {
        return  minStack.peek();
    }
}
